using System;
using UnityEditor;
using UnityEngine;

namespace Yoozoo.Core.Common.Editor
{
    [CustomEditor(typeof(ParticleGrading))]
    public class ParticleGradingEditor : UnityEditor.Editor
    {
        private ParticleGrading _particleGrading;
        private void OnEnable()
        {
            _particleGrading = target as ParticleGrading;
        }

        public override void OnInspectorGUI()
        {
            GUILayout.BeginHorizontal();
            
            if (GUILayout.Button("测试Level0",GUILayout.Height(35)))
            {
                if (!EditorApplication.isPlaying)
                {
                    EditorApplication.isPlaying = true;
                }
                
                _particleGrading.ChangeLevel(0);
                _particleGrading.gameObject.SetActive(false);
                _particleGrading.gameObject.SetActive(true);
            }
            
            if (GUILayout.Button("测试Level1",GUILayout.Height(35)))
            {
                if (!EditorApplication.isPlaying)
                {
                    EditorApplication.isPlaying = true;
                }
                _particleGrading.ChangeLevel(1);
                _particleGrading.gameObject.SetActive(false);
                _particleGrading.gameObject.SetActive(true);
            }
            
            if (GUILayout.Button("测试Level2",GUILayout.Height(35)))
            {
                if (!EditorApplication.isPlaying)
                {
                    EditorApplication.isPlaying = true;
                }
                _particleGrading.ChangeLevel(2);
                _particleGrading.gameObject.SetActive(false);
                _particleGrading.gameObject.SetActive(true);
            }
            
            GUILayout.EndHorizontal();
            
            base.OnInspectorGUI();
        }
    }
}